Get started topic
To get started, follow the package installation instructions and add a GoRouter configuration to your app:
import 'package:go_router/go_router.dart';
// GoRouter configuration
final _router = GoRouter(
routes: [
GoRoute(
path: '/',
builder: (context, state) => HomeScreen(),
),
],
);
To use this configuration in your app, use either the MaterialApp.router
or
CupertinoApp.router
constructor and set the routerConfig
parameter to your
GoRouter configuration object:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routerConfig: _router,
);
}
}
For a complete sample, see the Getting started sample in the example directory. For more on how to configure GoRouter, see Configuration.
Classes
- GoRoute Get started Configuration Redirection Transition animations Named routes
- A route that is displayed visually above the matching parent route using the Navigator.
- GoRoute Get started Configuration Redirection Transition animations Named routes
- A route that is displayed visually above the matching parent route using the Navigator.
- GoRouter Get started Upgrading Configuration Redirection Web Deep linking Named routes Error handling
- The route configuration for the app.
- GoRouter Get started Upgrading Configuration Redirection Web Deep linking Named routes Error handling
- The route configuration for the app.